import request from '@/utils/request'
/**
 *
 * @param {string} mobile
 * @param {string} code
 * @returns Promise
 */

export const loginAPI = (mobile, code) => {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data: {
      mobile,
      code
    }
  })
}
/**
 *
 * @param {string} mobile
 * @returns Promise
 */
export const getCodeAPI = (mobile) => {
  return request({
    url: `/v1_0/sms/codes/${mobile}`
  })
}
// 路径参数：手动拼接到url上
// 请求头参数：headers
// 查询(query)参数(get) params
// 请求头参数(body)参数(post，delete) data

export const getUserInfoAPI = () =>
  request({
    url: '/v1_0/user'
  })
/**
 *
 * @returns Promise
 */
export const getUserProfileAPI = () =>
  request({
    url: '/v1_0/user/profile'
  })
/**
 *
 * @param {*} data
 * @returns
 */
export const aditUserProfileAPI = (data) =>
  request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
export const uploadPhoto = (file) => {
  const fm = new FormData()
  fm.append('photo', file)
  return request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data: fm
  })
}
